package com.bcxj.routeplan.controller;

import com.bcxj.internalcommon.dto.RouteRecordDTO;
import com.bcxj.internalcommon.entity.RouteRecord;
import com.bcxj.internalcommon.response.ResponseResult;
import com.bcxj.routeplan.service.RouteRecordService;
import com.xiaoleilu.hutool.util.BeanUtil;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: RouteRecordController
 * Package: com.bcxj.routeplan.controller
 * Description: 路线记录相关操作
 *
 * @Author BCXJ
 * @Create 2025/4/24 12:40
 * @Version 1.0
 * @Since 1.0
 */
@RestController
@RequestMapping("/routerecord")
public class RouteRecordController {

    @Autowired
    private RouteRecordService recordService;


    /**
     * 增加路径选择
     * @param recordDTO
     * @return
     */
    @PostMapping("/add")
    public ResponseResult addRecord(@RequestBody RouteRecordDTO recordDTO) {
        System.out.println(recordDTO);
        RouteRecord record = new RouteRecord();
        BeanUtil.copyProperties(recordDTO, record);
        return recordService.add(record);
    }


    /**
     * 查询用户的历史的出行选择数据
     * @return
     */
    @GetMapping("list")
    public ResponseResult list(Long userId) {
        return recordService.list(userId);
    }





}
